#include "GAlign.h"

uint16_t
g_align_scale_sx(const GAlign   align,
                 const uint16_t sx,
                 const uint16_t ex,
                 const uint16_t width)
{
        if (align & G_ALIGN_LEFT)
                return sx;
        if (align & G_ALIGN_RIGHT)
                return ex - width;
        return (ex - sx - width) / 2 + sx;
}

uint16_t
g_align_scale_sy(const GAlign   align,
                 const uint16_t sy,
                 const uint16_t ey,
                 const uint16_t height)
{
        if (align & G_ALIGN_TOP)
                return sy;
        if (align & G_ALIGN_BOTTOM)
                return ey - height;
        return (ey - sy - height) / 2 + sy;
}
